<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <a-form size="small" :model="pageData.queryData" layout="inline">
          <!-- <a-col :span="6">
              <a-form-item :label-col-flex="pageData.labelColFlex1" label="日期">
                  <a-range-picker  popup-container="html"  class="bacClass" v-model="pageData.createTimeArr"/>
              </a-form-item>
            </a-col> -->
          <a-col :span="6">
            <a-form-item
              label="部门"
              field="departmentId"
              :label-col-flex="pageData.labelColFlex1"
              :validate-trigger="['change', 'blur']"
              :rules="[{ required: true, message: '部门必填' }]"
            >
              <a-cascader
                v-model="pageData.queryData.departmentId"
                :options="pageData.departmentTree"
                ref="casOb3"
                class="bacClass"
                :check-strictly="true"
                allow-clear
                popup-container="html"
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="流转卡号">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.circulatCard"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="色称">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.colorName"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="客户名称">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.customName"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="计划单号">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.planCode"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="检验结果">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.verifyResult"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="回修原因">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.repairReason"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="回修部门编号">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.repairDepartmentCode"
                allow-clear
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item :label-col-flex="pageData.labelColFlex1" label="回修部门名称">
              <a-input
                @press-enter="selectHandler"
                class="bacClass"
                v-model="pageData.queryData.repairDepartmentName"
                allow-clear
              />
            </a-form-item>
          </a-col>
        </a-form>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up
            v-if="headerShow"
            @click="headerShow = false"
            :strokeWidth="2"
            :size="18"
          />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
      <div class="my-tool-bar">
        <Toolbar
          v-if="pageData.toolbarShow"
          :items="['查询', '新增', '删除']"
          @add="addHandler"
          @del="deleteHandler"
          @select="selectHandler"
        >
        </Toolbar>
        <Toolbar v-else :items="['查询']" @select="selectHandler"> </Toolbar>
      </div>
    </template>
    <template #pageTabel>
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        rowSelection="multiple"
        @grid-ready="gridReady"
        style="height: 100%"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="table.dataList"
        :columnDefs="tc"
        :localeText="localeText1"
        :suppressRowClickSelection="true"
      ></AgGridVuesCopys>
    </template>

    <paginationCopys
      :page-size="pagination.pageSize"
      :current="pagination.page"
      :total="pagination.total"
      show-total
      show-jumper
      show-page-size
      @change="nextDoRefreshPage"
      @page-size-change="nextDoRefreshSize"
      style="justify-content: center"
    />

    <a-drawer
      placement="bottom"
      :drawer-style="{ zIndex: 9999 }"
      :mask-closable="false"
      height="80%"
      :visible="pageData.showAdd"
      unmountOnClose
      @ok="sideOk"
      @cancel="pageData.showAdd = false"
      cancel-text="关闭"
      ok-text="保存"
    >
      <template #title>
        {{ pageData.sideTitle }}
      </template>
      <div>
        <a-form ref="formRef" :model="dataForm" layout="horizontal">
          <a-row>
            <a-col :span="6">
              <a-form-item
                label="部门"
                field="departmentId"
                :label-col-flex="pageData.labelColFlex"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '部门必填' }]"
              >
                <a-cascader
                  v-model="dataForm.departmentId"
                  :options="pageData.departmentTree"
                  ref="casOb3"
                  class="bacClass"
                  :check-strictly="true"
                  allow-clear
                  popup-container="html"
                />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="客户订单号"
                field="customOrderCode"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '客户订单号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.customOrderCode" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="客户名称"
                field="customName"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '客户名称必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.customName" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="流传卡号"
                field="circulatCard"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '流传卡号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.circulatCard" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="缸号"
                field="cylinderNo"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '缸号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.cylinderNo" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="色称"
                field="colorName"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '色称必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.colorName" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="色号"
                field="colorCode"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '色号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.colorCode" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="匹数"
                field="houseNum"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '匹数必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.houseNum" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="重量"
                field="weight"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '重量必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.weight" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="布号"
                field="clothCode"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '布号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.clothCode" />
              </a-form-item>
            </a-col>

            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="品名"
                field="brandName"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '品名必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.brandName" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="计划单号"
                field="planCode"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '计划单号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.planCode" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="班次"
                field="shift"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '班次必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.shift" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="检验结果"
                field="verifyResult"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '检验结果必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.verifyResult" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="资料员"
                field="documenter"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '资料员必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.documenter" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="对色师傅"
                field="colormatchPerson"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '对色师傅必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.colormatchPerson" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="门幅"
                field="width"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '门幅必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.width" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="生产车间"
                field="workShop"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '生产车间必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.workShop" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="克重"
                field="gramWeight"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '克重必填' }]"
              >
                <a-input-number class="bacClass" v-model="dataForm.gramWeight" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="回修部门名称"
                field="repairDepartmentName"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '测试类型必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.repairDepartmentName" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="回修部门编号"
                field="repairDepartmentCode"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '回修部门编号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.repairDepartmentCode" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="合约号"
                field="contractNo"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '合约号必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.contractNo" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="回修原因"
                field="repairReason"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '测试类型必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.repairReason" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="客户意见"
                field="customOpinion"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '客户意见必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.customOpinion" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="快速牢度结果"
                field="fastSolidityResult"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '快速牢度结果必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.fastSolidityResult" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="对色类型"
                field="colormatchType"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '对色类型必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.colormatchType" />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="色级"
                field="colorLevel"
                :validate-trigger="['change', 'blur']"
                :rules="[{ required: true, message: '色级必填' }]"
              >
                <a-input class="bacClass" v-model="dataForm.colorLevel" />
              </a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item
                :label-col-flex="pageData.labelColFlex"
                label="备注"
                field="remark"
                :validate-trigger="['change', 'blur']"
              >
                <a-textarea class="bacClass" v-model="dataForm.remark" />
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-drawer>
  </pageTabelLayout>
</template>

<script lang="ts">
  import { post, get } from '@/api/http'
  import { useTable, usePagination, useTableColumn } from '@/hooks/table'

  import { ref, reactive, onMounted } from 'vue'
  import Toolbar from '@/components/Toolbar.vue'
  import { Message, Modal } from '@arco-design/web-vue'
  import { FormInstance } from '@arco-design/web-vue/es/form'
  import 'ag-grid-community/styles/ag-grid.css'
  import 'ag-grid-community/styles/ag-theme-alpine.css'
  import { localeText } from '@/api/aggridZw'
  
  import { slicing } from '@/utils/caseFrimAndSecRig'

  interface paramData {
    id: any
    recordCode: string | undefined
    circulatCard: string | undefined //流转卡号
    cylinderNo: string | undefined //缸号
    department: string | undefined //部门
    customOrderCode: string | undefined //客户订单号
    customName: string | undefined //客户名称
    colorCode: string | undefined //订单号
    colorName: string | undefined //色称
    weight: string | undefined //重量
    clothCode: string | undefined //布号
    brandName: string | undefined //品名
    pieceNum: string | undefined //件数
    planCode: string | undefined //计划单号
    shift: string | undefined //班次
    verifyResult: string | undefined //检验结果
    auditPerson: string | undefined //审核人
    documenter: string | undefined //资料员
    colormatchPerson: string | undefined //对色师傅
    width: string | undefined //门幅
    gramWeight: any //克重
    repairDepartmentName: string | undefined //回修部门名称
    repairDepartmentCode: string | undefined //回修部门编号
    workShop: string | undefined //生产车间
    customOpinion: string | undefined //客户意见
    contractNo: string | undefined //合约号
    repairReason: string | undefined //回修原因
    fastSolidityResult: string | undefined //快速牢度结果
    colormatchType: string | undefined //对色类型
    colorLevel: string | undefined //色级
    remark: string | undefined //备注
  }

  export default {
    //中检对色
    name: 'InspectionAndColorMatching',
    setup() {
      //隐藏显示头部
      const headerShow = ref<boolean>(true)
      const pageData = reactive<{
        showAdd: boolean
        sideTitle: string
        dropDownData: any
        pageLoading: boolean
        theight: number
        rHeight: number | undefined
        labelColFlex: string
        queryData: any
        toolbarShow: any
        submitState: any
        departmentTree: any
        createTimeArr: any
        labelColFlex1: string
      }>({
        showAdd: false,
        sideTitle: '新增中检对色',
        dropDownData: '',
        pageLoading: false,
        theight: 0,
        rHeight: 0,
        labelColFlex: '120px',
        queryData: {
          circulatCard: '',
          colorName: '',
          customName: '',
          planCode: '',
          verifyResult: '',
          repairReason: '',
          repairDepartmentCode: '',
          repairDepartmentName: '',
          departmentId: '',
          // startDate: '',
          // endDate: ''
        },
        toolbarShow: true,
        submitState: 0,
        departmentTree: [],
        createTimeArr: [],
        labelColFlex1: '100px',
      })
      const dataForm = reactive<any>({
        id: null,
        recordCode: '',
        circulatCard: '', //流转卡号
        cylinderNo: '', //缸号
        department: '', //部门
        departmentId: '',
        customOrderCode: '', //客户订单号
        customName: '', //客户名称
        colorCode: '', //订单号
        colorName: '', //色称
        weight: '', //重量
        clothCode: '', //布号
        brandName: '', //品名
        pieceNum: '', //件数
        planCode: '', //计划单号
        shift: '', //班次
        verifyResult: '', //检验结果
        auditPerson: '', //审核人
        documenter: '', //资料员
        colormatchPerson: '', //对色师傅
        width: '', //门幅
        gramWeight: 0, //克重
        repairDepartmentName: '', //回修部门名称
        repairDepartmentCode: '', //回修部门编号
        workShop: '', //生产车间
        customOpinion: '', //客户意见
        contractNo: '', //合约号
        repairReason: '', //回修原因
        fastSolidityResult: '', //快速牢度结果
        colormatchType: '', //对色类型
        colorLevel: '', //色级
        remark: '', //备注
        houseNum: '', //匹数
      })
      //查询列表
      onMounted(() => {
        selectHandler()
        getBmGroup()
      })

      //切换分页
      const nextDoRefreshPage = (val: any) => {
        pagination.page = val
        doRefresh()
      }
      const nextDoRefreshSize = (val: any) => {
        pagination.pageSize = val
        doRefresh()
      }
      const pagination = usePagination(doRefresh)
      const table = useTable()
      function doRefresh() {
        pageData.pageLoading = true
        pageData.queryData.page = pagination.page
        pageData.queryData.size = pagination.pageSize
        if (pageData.createTimeArr == undefined) {
          pageData.createTimeArr = []
        }
        pageData.queryData.startDate = pageData.createTimeArr[0]
        pageData.queryData.endDate = pageData.createTimeArr[1]
        post({
          url: 'dwQms/ColorMatch/getPage',
          data: pageData.queryData,
        })
          .then(({ data, code }: any) => {
            if (code === 200) {
              table.handleSuccess(data.list)
              pagination.setTotalSize(data.total)
              gridOption.value.setRowData(data.list)
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }
      //查询
      const selectHandler = () => {
        pagination.page = 1
        doRefresh()
      }
      //------新增、修改页面开始------
      const addHandler = () => {
        // getBmGroup()
        for (var key in dataForm) {
          if (key === 'id') {
            dataForm[key] = null
          } else {
            dataForm[key] = ''
          }
        }
        pageData.showAdd = true
        pageData.sideTitle = '新增中检对色'
      }
      const casOb3 = ref<any>(null)
      watch(
        () => dataForm.departmentId,
        (newVal) => {
          nextTick(() => {
            dataForm.department = casOb3.value.selectViewValue[0].label
          })
        }
      )
      const editHandler = (record: paramData) => {
        getBmGroup()
        for (var key in record) {
          dataForm[key] = record[key]
        }
        pageData.sideTitle = '修改中中检对色'
        pageData.showAdd = true
      }

      const formRef = ref<FormInstance>()
      const sideOk = () => {
        formRef.value?.validate().then((err) => {
          if (!err) {
            if (pageData.sideTitle === '新增中检对色') {
              post({
                url: 'dwQms/ColorMatch/insert',
                data: [dataForm],
              }).then((res: any) => {
                if (res.code === 200) {
                  formRef.value?.resetFields()

                  pageData.showAdd = false

                  Message.success({
                    content: '新增成功',
                    duration: 5000,
                  })
                  selectHandler()
                } else {
                  Message.error({
                    content: res.message,
                    duration: 5000,
                  })
                }
              })
            } else {
              post({
                url: 'dwQms/ColorMatch/update',
                data: [dataForm],
              }).then((res: any) => {
                if (res.code === 200) {
                  formRef.value?.resetFields()
                  pageData.showAdd = false

                  Message.success({
                    content: '修改成功',
                    duration: 5000,
                  })
                  selectHandler()
                } else {
                  Message.error({
                    content: res.message,
                    duration: 5000,
                  })
                }
              })
            }
          }
        })
      }
      //------新增、修改页面结束------
      //------删除方法开始------
      const deleteHandler = () => {
        if (gridOption.value.getSelectedRows().length === 0) {
          return
        }
        Modal.confirm({
          title: '系统提示',
          content: '确认删除选中的数据?',
          onOk() {
            post({
              url: 'dwQms/ColorMatch/delete',
              data: gridOption.value.getSelectedRows().map((o: any) => {
                return o.id
              }),
            }).then(({ code, data }: any) => {
              if (code === 200) {
                Message.success({
                  content: '删除成功',
                  duration: 5000,
                })

                pagination.page = 1
                selectHandler()
              } else {
                Message.error({
                  content: '删除失败',
                  duration: 5000,
                })
              }
            })
          },
        })
      }
      // 获取部门列表
      const getBmGroup = () => {
        post({
          url: 'org/baCompany/getDepartmentTree?companyId=' + 12,
        }).then((result) => {
          if (result.code === 200) {
            pageData.departmentTree = result.data
          }
        })
      }
      //------删除方法结束------

      // 表格准备事件
      const tableColumns = useTableColumn([
        {
          title: '序号',
          key: 'id',
          dataIndex: 'id',
          width: '150px',
        },
        {
          title: '部门',
          key: 'department',
          dataIndex: 'department',
        },
        {
          title: '检验日期',
          key: 'createTime',
          dataIndex: 'createTime',
        },
        {
          title: '回修部门名称',
          key: 'repairDepartmentName',
          dataIndex: 'repairDepartmentName',
        },
        {
          title: '资料员',
          key: 'documenter',
          dataIndex: 'documenter',
        },
        {
          title: '班次',
          key: 'shift',
          dataIndex: 'shift',
        },
        {
          title: '记录单号',
          key: 'recordCode',
          dataIndex: 'recordCode',
        },
        {
          title: '流转卡号',
          key: 'circulatCard',
          dataIndex: 'circulatCard',
        },
        {
          title: '客户名称',
          key: 'customName',
          dataIndex: 'customName',
        },
        {
          title: '客户订单号',
          key: 'customOrderCode',
          dataIndex: 'customOrderCode',
        },
        {
          title: '布号',
          key: 'clothCode',
          dataIndex: 'clothCode',
        },
        {
          title: '品名',
          key: 'brandName',
          dataIndex: 'brandName',
        },
        {
          title: '色号',
          key: 'colorCode',
          dataIndex: 'colorCode',
        },
        {
          title: '色称',
          key: 'colorName',
          dataIndex: 'colorName',
        },
        {
          title: '缸号',
          key: 'cylinderNo',
          dataIndex: 'cylinderNo',
        },
        {
          title: '重量',
          key: 'weight',
          dataIndex: 'weight',
        },
        {
          title: '匹数',
          key: 'pieceNum',
          dataIndex: 'pieceNum',
        },
        {
          title: '回修原因',
          key: 'repairReason',
          dataIndex: 'repairReason',
        },
        {
          title: '检验结果',
          key: 'verifyResult',
          dataIndex: 'verifyResult',
        },
        {
          title: '对色师傅',
          key: 'colormatchPerson',
          dataIndex: 'colormatchPerson',
        },
        {
          title: '门幅',
          key: 'width',
          dataIndex: 'width',
        },
        {
          title: '克重',
          key: 'gramWeight',
          dataIndex: 'gramWeight',
        },
        {
          title: '快速牢度结果',
          key: 'fastSolidityResult',
          dataIndex: 'fastSolidityResult',
        },
        {
          title: '对色类型',
          key: 'colormatchType',
          dataIndex: 'colormatchType',
        },
        {
          title: '生产车间',
          key: 'workShop',
          dataIndex: 'workShop',
        },
        {
          title: '修改人',
          key: 'updateName',
          dataIndex: 'updateName',
        },

        {
          title: '修改日期',
          key: 'updateTime',
          dataIndex: 'updateTime',
        },
        {
          title: '备注',
          key: 'remark',
          dataIndex: 'remark',
        },
        {
          title: '创建人',
          key: 'createName',
          dataIndex: 'createName',
        },
        {
          title: '创建时间',
          key: 'createTime',
          dataIndex: 'createTime',
        },
        {
          title: '操作',
          key: 'id',
          dataIndex: 'id',
          slotName: 'act',
          width: 150,
          fixed: 'right',
        },
      ])
      const gridOption = ref()
      const gridReady = (params: any) => {
        gridOption.value = params.api
      }
      const defaultColDef = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      let tc: any[] = tableColumns.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          width: o.width,
          children: o.children,
        }
        if (o.slotName === 'act') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['lockPosition'] = o.fixed
          obj['cellRenderer'] = {
            template: `<el-button style="color:#165dff;" link @click="a">修改</el-button>`,
            setup(props: any) {
              const a = () => {
                editHandler(props.params.data)
              }
              return {
                a,
              }
            },
          }
        }
        return obj
      })
      let a = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc = a.concat(tc)
      const localeText1: any = ref(localeText)
      return {
        deleteHandler,
        sideOk,
        formRef,
        dataForm,
        addHandler,
        pagination,
        table,
        pageData,
        editHandler,
        selectHandler,
        headerShow,
        nextDoRefreshPage,
        nextDoRefreshSize,
        defaultColDef,
        localeText1,
        tc,
        gridReady,
        gridOption,
        getBmGroup,
        casOb3,
      }
    },
    components: { Toolbar,  },
  }
</script>
<style scoped lang="less">
  :deep(.ag-cell) {
    border-right: 1px solid #dde2eb;
  }

  :deep(.ag-header-cell) {
    border-right: 1px solid #dde2eb;
  }

  :deep(.ag-cell-value) {
    user-select: initial;
    -moz-user-select: text;
    -ms-user-select: text;
    -webkit-user-select: text;
  }
</style>
